<template>
  <div class="profile-container">
    <el-card class="profile-card">
      <div class="profile-header">
        <div class="avatar-container">
          <img src="../static/img/迪迦点赞.jpg" alt="用户头像" class="avatar"/>
        </div>
        <h2 class="username">用户名</h2>
        <div class="user-info">
          <div class="info-item">
            <span class="label">注册天数</span>
            <span class="value">120天</span>
          </div>
          <div class="info-item">
            <span class="label">历史打卡</span>
            <span class="value">45天</span>
          </div>
          <div class="info-item">
            <span class="label">完成计划</span>
            <span class="value">3个</span>
          </div>
        </div>
      </div>

      <el-divider/>

      <!-- <div class="profile-stats">
        <h3 class="section-title">打卡统计</h3>
        <div class="stats-grid">
          <div class="stat-item">
            <div class="stat-value">45</div>
            <div class="stat-label">累计打卡天数</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">5</div>
            <div class="stat-label">本周打卡</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">15</div>
            <div class="stat-label">本月打卡</div>
          </div>
          <div class="stat-item">
            <div class="stat-value">3</div>
            <div class="stat-label">连续打卡</div>
          </div>
        </div>
      </div> -->

      <el-divider/>

      <div class="profile-actions">
        <el-button type="primary" plain icon="el-icon-edit">编辑资料</el-button>
        <el-button type="danger" @click="logout">退出登录</el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
import fetch from "@/api/fetch";

export default {
  name: 'ProfileView',
  data() {
    return {
      // 用户数据
    }
  },
  methods: {
    logout() {
      // 调用退出登录接口
      let paramInfo = {}
      fetch('/client-user/user/pc/logout', {paramInfo}, {method: 'post'});
      // 清除本地存储的token
      localStorage.removeItem('token');

      // 更新Vuex中的认证状态
      this.$store.dispatch('user/logout').then(() => {
        this.$message.success('退出登录成功');
        // 跳转到登录页
        this.$router.push('/login');
      });
    }
  }
}
</script>

<style scoped>
.profile-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.profile-card {
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
}

.avatar-container {
  margin-bottom: 20px;
}

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #FF6B6B;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.username {
  font-size: 24px;
  margin: 0 0 20px;
  color: #2D3436;
}

.user-info {
  display: flex;
  justify-content: center;
  gap: 30px;
  width: 100%;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.label {
  font-size: 14px;
  color: #606266;
  margin-bottom: 5px;
}

.value {
  font-size: 18px;
  font-weight: bold;
  color: #4A90E2;
}

.section-title {
  font-size: 18px;
  color: #2D3436;
  margin-bottom: 20px;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.stat-item {
  background-color: #f5f7fa;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  transition: transform 0.3s;
}

.stat-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: #FF6B6B;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 14px;
  color: #606266;
}

.profile-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 20px 0;
}

@media (max-width: 768px) {
  .user-info {
    flex-direction: column;
    gap: 15px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
</style>